<?php

/*
 * Elaboraco Por: Ebrain Cedeno.
 */

class TButton{
    
    public $Name;
    public $Width;
    public $Height;
    public $Top;
    public $Left;
    public $Visible;
    public $Font;
    public $FontColor;
    public $Color;
    public $Cursor;
    public $Align;
    public $Enabled = true;
    public $Submit = true;
    public $Caption;
    public $Aditional = array();
    
    public function show(){
        
        //agregando los valores de propiedades al boton
        
        $submit = ($this->Submit == true)?'submit':'button';
        $width = ($this->Width != "")?'width:'.$this->Width.";":'';
        $height = ($this->Height != "")?'height:'.$this->Height.';':'';
        $color = ($this->Color != "")?'background-color:'.$this->Color.';':'';
        $cursor = ($this->Cursor != "")?'cursor:'.$this->Cursor.';':'';
        $align = ($this->Align != "")?'text-align:'.$this->Align.';':'';
        $font = ($this->Font != "")?'font:'.$this->Font.';':'';
        $fontColor = ($this->FontColor !="")?'color:'.$this->FontColor.';':'';
        $top = ($this->Top != "")?'position:absolute; top:'.$this->Top.';':'';
        $left = ($this->Left != "")?'position:absolute; left:'.$this->Left.';':'';
        $enabled = ($this->Enabled == false)?'disabled="'.$this->Enabled.'"':'';
        
        //cargando los parametros adicionales
        
        $Aditional = '';
        $css_aditional = '';
        
        if (!is_array($this->Aditional)){
            die("Se esperaba un array de parametros adicionales");
        }
        else{
            if (count($this->Aditional) > 0){
                foreach ($this->Aditional as $llave=>$value){
                    if (strtolower($llave) != "style" ){
                        $Aditional .= $llave.'="'.$value.'" ';
                    }
                    else{
                        $css_aditional .= implode(';', $value).";";
                    }
                }
            }
        }
        
        
        $input = '<input name="'.$this->Name.'" id="'.$this->Name.'" '.$Aditional.' type="'.$submit.'" value="'.$this->Caption.'" style="'.$width.$height.$color.$cursor.$align.$font.$fontColor.$top.$left.$css_aditional.'" '.$enabled.' />';
        return $input;
        
    }
    
}

?>
